package br.unip.tcc.domotic.orm;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "andar")
public class Floor extends AbstractORM {
	
	private static final long serialVersionUID = 1L;
	
	private Integer floorId;
	private String floorName;
	private Short floorLevel;
	private Double floorArea;
	private byte[] floorImage;
	private Home home;
	private Set<Room> rooms = new HashSet<Room>(0);
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "cod_andar", unique = true, nullable = false)
	public Integer getFloorId() {
		return floorId;
	}
	
	public void setFloorId(Integer floorId) {
		this.floorId = floorId;
	}
	
	@Column(name = "nom_andar", nullable = false)
	public String getFloorName() {
		return floorName;
	}
	
	public void setFloorName(String floorName) {
		this.floorName = floorName;
	}
	
	@Column(name = "num_nivel", nullable = false)
	public Short getFloorLevel() {
		return floorLevel;
	}
	
	public void setFloorLevel(Short floorLevel) {
		this.floorLevel = floorLevel;
	}
	
	@Column(name = "val_area_andar", nullable = true)
	public Double getFloorArea() {
		return floorArea;
	}
	
	public void setFloorArea(Double floorArea) {
		this.floorArea = floorArea;
	}
	
	@Column(name = "dad_imagem", nullable = false)
	public byte[] getFloorImage() {
		return floorImage;
	}
	
	public void setFloorImage(byte[] floorImage) {
		this.floorImage = floorImage;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cod_residencia", nullable = false)
	public Home getHome() {
		return home;
	}
	
	public void setHome(Home home) {
		this.home = home;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "floor")
	public Set<Room> getRooms() {
		return rooms;
	}
	
	public void setRooms(Set<Room> rooms) {
		this.rooms = rooms;
	}
	
}
